﻿using Helpers;
using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace GmailChatBot
{
    public class CommandProcess
    {
        #region Properties

        protected string MsgNotSupported { get; set; }
        protected string MsgSuccess { get; set; }

        #endregion

        public CommandProcess() 
        {
            this.MsgNotSupported = "Not supported yet";
            this.MsgSuccess = "Success";
        }

        #region Methods

        public string Process(string command)
        {
            string response;

            if (string.IsNullOrEmpty(command) == false)
            {
                response = this.ProcessInternal(command.Trim().ToUpper());

                if (string.IsNullOrEmpty(response) == false)
                    response = this.MsgNotSupported;
            }
            else
            {
                response = this.MsgNotSupported;
            }

            return response;
        }
        protected virtual string ProcessInternal(string command)
        {
            return this.MsgNotSupported;
        }

        #endregion

        #region Static Methods

        protected static void SendKey(string key, Process proc)
        {
            IntPtr hWnd = proc.MainWindowHandle;

            /* Set as active the window of the tv program. */
            Processes.SetForegroundWindow(hWnd);

            /* Send key to application. */
            SendKeys.SendWait(key);
        }

        #endregion
    }
}
